package com.direction.hold.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.ListView;
import cn.cheln.explorer.actions.OperationUtil;
import cn.cheln.explorer.actions.sort.ObjectSort;
import cn.cheln.explorer.actions.sort.Sort;
import cn.cheln.explorer.beans.FileInfo;
import cn.cheln.explorer.beans.FileInfoUtil;
import cn.cheln.explorer.config.Config;
import cn.cheln.explorer.cpnt.adapter.FileAdapter;
import cn.cheln.explorer.cpnt.adapter.ThumbnailAdapter;
import cn.cheln.explorer.ds.sdcard.HiddenFilter;
import cn.cheln.explorer.ds.uri.NavigationConstants;
import cn.cheln.explorer.ds.uri.NavigationNode;
import cn.cheln.explorer.ds.uri.NavigationPool;
import cn.cheln.explorer.ds.uri.SDCardNode;
import cn.cheln.explorer.ui.ViewUtil;
import cn.cheln.support.log.Logs;
import cn.cheln.support.mobile.sdcard.SDcardChecker;
import cn.cheln.support.ui.adapter.ItemDataSrc;
import cn.cheln.support.ui.adapter.MapAdapter;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Stack;

public class PathActivity extends CommonActivity
{
  protected static final int SWIPE_LAZY;
  public static PathActivity activityInstance;
  public static boolean codePerformed = false;
  public String extRequired = null;
  List<FileInfo> fileInfos = null;
  boolean refereshFlag;
  public ReadRuntime rrt = new ReadRuntime();

  private boolean fileNavigation(MenuItem paramMenuItem)
  {
    if (-100 + paramMenuItem.getItemId() < this.navTool.navEntity.size())
    {
      makeSelectAll(false, false);
      int i = -1 + this.navTool.navEntity.size() - (-100 + paramMenuItem.getItemId());
      NavigationNode localNavigationNode = this.navTool.backward(i);
      access(localNavigationNode, localNavigationNode.defaultPosition, true, 1, OperationUtil.mOperationState.intValue());
      showBottomBar(8);
      return true;
    }
    return false;
  }

  private void passCut_Copy(int paramInt)
  {
    OperationUtil.mOperationState = Integer.valueOf(1);
    firstTimeStartup(0, true, 0);
    cutOrCopy(paramInt);
  }

  public void access(NavigationNode paramNavigationNode, int paramInt1, boolean paramBoolean, int paramInt2, int paramInt3)
  {
    access(paramNavigationNode, paramInt1, paramBoolean, paramInt2, paramInt3, -1);
  }

  protected void access(NavigationNode paramNavigationNode, int paramInt1, boolean paramBoolean, int paramInt2, int paramInt3, int paramInt4)
  {
    try
    {
      this.filesInfo = setupPrevUILoad();
      this.accessFlag = paramInt2;
      this.newPos = paramInt1;
      this.navigation = paramNavigationNode;
      this.status = paramInt3;
      if (this.fileInfos != null)
        this.fileInfos = null;
      this.fileInfos = new ArrayList(0);
      File[] arrayOfFile = ((FileInfo)this.navigation.producingSource).getFile().listFiles(new HiddenFilter(Config.SDCARD_HIDE_OPTION));
      FileInfoUtil.getFileInfos(this.fileInfos, getReadInfoClass(), arrayOfFile, this.context, this.extRequired);
      if (!(this.fileInfos.isEmpty()))
      {
        Sort localSort = this.policy;
        label141: if (localSort == null);
      }
    }
    catch (Exception localException1)
    {
      try
      {
        Collections.sort(this.fileInfos, (ObjectSort)this.policy);
        refreshSDcardReadView(this.status, paramNavigationNode, paramInt1, paramInt2);
        return;
      }
      catch (Exception localException2)
      {
        localException2.printStackTrace();
        break label141:
        localException1 = localException1;
        localException1.printStackTrace();
      }
    }
  }

  protected void cutOrCopy(int paramInt)
  {
    OperationUtil.mOperationState = Integer.valueOf(1);
    this.operationUtil.setCommand(paramInt);
    showBottomBar(8);
    showPasteToolBar(0);
    makeSeenToAll(false);
    if ((CountActivity.categoryActivity != null) && (CountActivity.categoryActivity.adapter != null))
      CountActivity.categoryActivity.makeSeenToAll(false);
    this.mStateCheckBoxVisible = false;
    this.mState = Integer.valueOf(1);
  }

  public void firstTimeStartup()
  {
    firstTimeStartup(0, false, 350);
  }

  public void firstTimeStartup(int paramInt1, boolean paramBoolean, int paramInt2)
  {
    if (SDcardChecker.srcardStateResolve(true, this));
    do
      return;
    while (codePerformed);
    codePerformed = true;
    if (!(paramBoolean))
    {
      turnToFileBrowsing(this.viewHandlers, this.listItemClickListener, new SDCardNode(new FileInfo(new File(NavigationConstants.SDCARD_PATH), this.context)), Integer.valueOf(0).intValue());
      return;
    }
    SDCardNode localSDCardNode = (SDCardNode)this.navTool.navEntity.peek();
    try
    {
      access(localSDCardNode, localSDCardNode.defaultPosition, true, 2, OperationUtil.mOperationState.intValue(), Integer.valueOf(0).intValue());
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  protected String getEmptyText()
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = getString(2131034198);
    return getString(2131034118, arrayOfObject);
  }

  public int[] getMenuIds()
  {
    return new int[] { 2131230902, 2131230904, 2131230903, 2131230905 };
  }

  public String getNavBarWholeShowText()
  {
    return this.navTool.getShowText();
  }

  public Class<? extends NavigationNode> getNavNodeClazz()
  {
    return SDCardNode.class;
  }

  public Class<? extends FileInfo> getReadInfoClass()
  {
    return FileInfo.class;
  }

  public void gotoCat()
  {
  }

  public void handlerRead(Object paramObject, boolean paramBoolean)
  {
  }

  protected boolean navigate(MenuItem paramMenuItem)
  {
    return fileNavigation(paramMenuItem);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    activityInstance = this;
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    if (OperationUtil.mOperationState.intValue() == 1);
    do
      return false;
    while (SDcardChecker.srcardStateResolve(true, this));
    super.onCreateOptionsMenu(paramMenu);
    paramMenu.add(0, 22, 0, getString(2131034266));
    paramMenu.add(0, 23, 0, getString(2131034279));
    paramMenu.findItem(22).setIcon(2130837513);
    paramMenu.findItem(23).setIcon(2130837553);
    hideMusicMenu(paramMenu.findItem(2131230900).getSubMenu(), false);
    return true;
  }

  public boolean onPrepareOptionsMenu(Menu paramMenu)
  {
    super.onPrepareOptionsMenu(paramMenu);
    MenuItem localMenuItem = paramMenu.findItem(23);
    if (Config.SDCARD_HIDE_OPTION);
    for (String str = getString(2131034279); ; str = getString(2131034281) + getString(2131034279))
    {
      localMenuItem.setTitle(str);
      return true;
    }
  }

  protected void onStart()
  {
    super.onStart();
    if ("com.lewa.filemgr.path_start".equals(getIntent().getAction()))
    {
      this.extRequired = getIntent().getStringExtra("com.lewa.filemgr.path_start.file_ext");
      getIntent().getStringExtra("CALLBACK_ACTION");
      if (this.extRequired != null)
        this.listItemClickListener = new CommonActivity.ListItemClickListener(this)
        {
          public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
          {
            FileInfo localFileInfo = (FileInfo)paramAdapterView.getItemAtPosition(paramInt);
            if ((((ThumbnailAdapter)paramAdapterView.getAdapter()).hasSelected()) && (OperationUtil.mOperationState.intValue() != 1))
            {
              if (!(localFileInfo.isDir.booleanValue()))
                ((CheckBox)ViewUtil.findViewById(paramView, 2131230801)).performClick();
              return;
            }
            PathActivity.this.enterDir(localFileInfo);
          }
        };
    }
    this.handler.postDelayed(new Runnable()
    {
      public void run()
      {
        PathActivity.this.handler.sendEmptyMessage(12);
      }
    }
    , 130L);
    this.navTool.navEntity.clear();
    this.navTool.navEntity.push(new SDCardNode(new FileInfo(new File(NavigationConstants.SDCARD_PATH), this), NavigationConstants.SDCARD));
  }

  public void recovery()
  {
    setSort();
    firstTimeStartup(0, true, 0);
  }

  public void refreshSDcardReadView(int paramInt1, NavigationNode paramNavigationNode, int paramInt2, int paramInt3)
  {
    createBrowseView(getViewHandlers(), getOnClickListener(), true);
    this.adapter.clearDataSrc();
    this.adapter.notifyDataSetChanged();
    ItemDataSrc localItemDataSrc = new ItemDataSrc(this.fileInfos);
    this.adapter.reinitSelectedAllBck(localItemDataSrc.getCount());
    this.adapter.setItemDataSrc(localItemDataSrc);
    if (this.adapter.getCount() != 0)
      this.adapter.notifyDataSetChanged();
    new Thread(new Runnable()
    {
      FileInfo fileInfo;
      HiddenFilter hiddenFilter = new HiddenFilter(Config.SDCARD_HIDE_OPTION);

      public void run()
      {
        int i = 0;
        label2: if (i >= PathActivity.this.adapter.getCount());
        do
        {
          return;
          this.fileInfo = ((FileInfo)PathActivity.this.adapter.getItem(i));
        }
        while (!(this.fileInfo.getIsDir().booleanValue()));
        if (PathActivity.this.extRequired != null)
          this.fileInfo.countStr = "";
        while (true)
        {
          ++i;
          break label2:
          this.fileInfo.getFile().list(this.hiddenFilter);
          this.fileInfo.setCount(Integer.valueOf(this.hiddenFilter.getCount()));
          this.fileInfo.buildCountStr();
          this.hiddenFilter.clearCount();
          PathActivity.this.handler.sendEmptyMessage(6);
        }
      }
    }).start();
    setupAfterUILoad(paramInt1, paramNavigationNode, paramInt2, this.accessFlag, this.filesInfo);
    navigationBarSetup(paramInt2, paramInt3, paramNavigationNode);
  }

  protected void setHiddenFileShowFlag()
  {
    this.isHiddenFileShow = Config.SDCARD_HIDE_OPTION;
  }

  protected void setNavigationPosAndNode(int paramInt1, int paramInt2, NavigationNode paramNavigationNode)
  {
    boolean bool;
    int i;
    FileInfo localFileInfo = (FileInfo)paramNavigationNode.producingSource;
    StringBuilder localStringBuilder = new StringBuilder("this.navTool.navEntity.peek() ------------- ");
    if (paramInt2 == 0)
    {
      bool = true;
      label28: Logs.i(bool + " " + this.navTool.navEntity.peek());
      if (paramInt2 != 0)
        break label213;
      if (this.navTool.navEntity.size() != 0)
        ((SDCardNode)this.navTool.navEntity.peek()).setClickPosition(paramInt1);
      if (!(localFileInfo.getPath().equals(NavigationConstants.SDCARD_PATH)))
        this.navTool.push(NavigationNode.buildNode(paramNavigationNode.getClass(), localFileInfo));
      if ((!(this.navTool.navEntity.isEmpty())) && (((NavigationNode)this.navTool.navEntity.peek()).displayname != null) && (((NavigationNode)this.navTool.navEntity.peek()).displayname.equals(NavigationConstants.SDCARD)))
        ((SDCardNode)this.navTool.navEntity.peek()).defaultPosition = -1;
      this.listview.setSelection(0);
    }
    do
    {
      do
      {
        return;
        bool = false;
        label213: break label28:
      }
      while (paramInt2 != 1);
      i = ((SDCardNode)this.navTool.navEntity.peek()).defaultPosition;
    }
    while (i == -1);
    this.listview.setSelection(i);
  }

  public void sort()
  {
    if (this.adapter == null)
      return;
    Collections.sort((List)this.adapter.getItemDataSrc().getContent(), (ObjectSort)this.policy);
    Logs.i("----------policy " + this.policy.getPolicy());
    this.adapter.notifyDataSetChanged();
  }

  public void startup()
  {
    if (!(codePerformed))
      return;
    turnToFileBrowsing(getViewHandlers(), getOnClickListener(), new SDCardNode(new FileInfo(new File(getSDcardPath()), this)));
  }

  public void switchToCutCopy()
  {
    if (SlideActivity.paramActivity.isInOperation != -1)
      passCut_Copy(SlideActivity.paramActivity.isInOperation);
    do
      return;
    while ((OperationUtil.getOperType() != 0) && (OperationUtil.getOperType() != 1));
    passCut_Copy(OperationUtil.getOperType());
  }

  protected void swithToPrivacyActivity()
  {
  }

  public static class ReadRuntime
  {
    public int listviewPos = -1;
    public NavigationNode navNode;
    public int readMode = -1;
    public int status = -1;
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     com.direction.hold.ui.PathActivity
 * JD-Core Version:    0.5.2
 */